﻿using System;
using System.Web.UI;
using System.Web.Configuration;
using System.Data;
using System.Web.UI.WebControls;

public partial class manager_temt_TaskFp_Default : System.Web.UI.Page
{
    public string Html_Dept = "";
    public string Html_Dept_Detail = "";
    DBHelper db = new DBHelper(WebConfigurationManager.ConnectionStrings["connString"].ConnectionString);
    protected void Page_Load(object sender, EventArgs e)
    {
        ((Label)Master.FindControl("MESS")).Text = (Request.QueryString["mes"]);
        if (!IsPostBack)
        {
            GetDept();
            loadData();
        }
    }

    private void GetDept()
    {
        int i = 0;
        Html_Dept = "";
        DataTable dt = db.getList("select * from dict_dept where [isUsing]=1 order by id");
        foreach (DataRow dr in dt.Rows)
        {
            if (i == 0)
            {
                Html_Dept += "<li onclick=\"SetDept('" + dr["id"].ToString() + "','" + dr["mc"].ToString() + "')\" role=\"presentation\" class=\"active\"><a href=\"#dept_" + dr["id"].ToString() + "\" role=\"tab\" data-toggle=\"tab\">" + dr["mc"].ToString() + "</a></li>";
            }
            else
            {
                Html_Dept += "<li onclick=\"SetDept('" + dr["id"].ToString() + "','" + dr["mc"].ToString() + "')\"  role=\"presentation\"><a href=\"#dept_" + dr["id"].ToString() + "\" role=\"tab\" data-toggle=\"tab\">" + dr["mc"].ToString() + "</a></li>";
            }
            i = 1;
        }
    }

    private void loadData()
    {
        dept_id.Value = "";
        int i = 0;
        DataTable dt = db.getList("select * from dict_dept where [isUsing]=1 order by id");
        foreach (DataRow dr in dt.Rows)
        {
            dept_id.Value = dept_id.Value + "|" + dr["id"].ToString();
            if (i == 0)
            { Html_Dept_Detail += "<div role=\"tabpanel\" class=\"tab-pane active\" id=\"dept_" + dr["id"].ToString() + "\">"; }
            else
            { Html_Dept_Detail += "<div role=\"tabpanel\" class=\"tab-pane\" id=\"dept_" + dr["id"].ToString() + "\">"; }

            Html_Dept_Detail += "<div class=\"box-body\">";
            Html_Dept_Detail += "<table id=\"table_" + dr["id"].ToString() + "\" class=\"table table-bordered table-striped\">";
            Html_Dept_Detail += "<thead>";
            Html_Dept_Detail += "<tr>";
            Html_Dept_Detail += "<th></th>";
            Html_Dept_Detail += "<th  class=\"col-sm-5\">标题</th>"; 
            Html_Dept_Detail += "<th class=\"col-sm-3\">考核岗位</th>";
            Html_Dept_Detail += "<th class=\"col-sm-3\">被考核岗位</th>";
            Html_Dept_Detail += "<th class=\"col-sm-1\"></th>";
            Html_Dept_Detail += "</tr>";
            Html_Dept_Detail += "</thead>";
            Html_Dept_Detail += "<tbody>";

            string tsql = "select * from v_dict_dept_position_Task  where (dept_kh=" + dr["id"].ToString()+ " or dept_bkh=" + dr["id"].ToString() + ") order by id";

            DataTable dt1 = db.getList(tsql);
            foreach (DataRow dr1 in dt1.Rows)
            {
                Html_Dept_Detail += "<asp:Repeater runat=\"server\">";
                Html_Dept_Detail += "<ItemTemplate>";
                Html_Dept_Detail += "<tr>";
                Html_Dept_Detail += "<td>" + dr1["id"].ToString() + "</td>";
                Html_Dept_Detail += "<td>" + SQ_Eval_Pub.Get_LX_TYPE(dr1["LX_TYPE"].ToString()) + dr1["title"].ToString() + "</td>"; 
                Html_Dept_Detail += "<td>" + dr1["Ry_Kh_Gw"].ToString() + "</td>";
                Html_Dept_Detail += "<td>" + dr1["Ry_Bkh_Gw"].ToString() + "</td>";
                Html_Dept_Detail += "<td><a  href=\"viewKh.aspx?id=" + dr1["id"].ToString() + "\">考核</a>   <a href=\"viewBKh.aspx?id=" + dr1["id"].ToString() + "\">被考</a></td>";
                Html_Dept_Detail += "</tr>";
            }
            Html_Dept_Detail += "</tbody>";
            Html_Dept_Detail += "</table>";
            Html_Dept_Detail += "</div>";
            Html_Dept_Detail += "</div>";
            i = 1;
        }
    }
}